class Solution {
        List<List<Integer>> re = new ArrayList<List<Integer>>();
        List<Integer> temp = new ArrayList<>();
    public List<List<Integer>> combinationSum2(int[] candidates, int target) {
        //排序

        Arrays.sort(candidates);
        add(candidates,0,target);
        return re;
    }
    public void add(int[] candidates , int begin , int target){
        int len = candidates.length;
        if(target == 0){
            re.add(new ArrayList<Integer>(temp));
            return;
        }
        for( int i = begin ; i < len ; i++){
            //剪枝
            if(candidates[i] > target) break;
            //避免了 一个数重复出现的情况
            if(i > begin && candidates[i-1] == candidates[i])continue;
            temp.add(candidates[i]);
            add(candidates,i+1,target - candidates[i]);
            temp.remove(temp.size()-1);
            
        }
    }
}